<include file="Public/min-header"/>

<!--物流配置 css -start-->
<style>
    ul.group-list {
        width: 96%;min-width: 1000px; margin: auto 5px;list-style: disc outside none;
    }
    ul.group-list li { 
        white-space: nowrap;float: left;
        width: 150px; height: 25px;
        padding: 3px 5px;list-style-type: none;
        list-style-position: outside;border: 0px;margin: 0px;
    }
/* 	.edui-editor{height: 355px;} */
	.mygood{display:none;}
	#mydel{width: 22px;height:24px;position: absolute; margin: -15px;cursor: pointer;}
	select:-internal-list-box:enabled option:checked:enabled:hover {background:#374064;color:#fff;}
	#fenlei_box{border: 1px solid #3297ff;position: absolute;width:300px;height:250px;overflow-y: auto; z-index:9999;background:#fff;display:none;}
	#fenlei_box li{list-style: none;color:#3297ff;text-align:center;margin-left:-40px;line-height: 32px;cursor: pointer;}
</style>
<!--物流配置 css -end-->
<?php $myurl="https://".$_SERVER['SERVER_NAME'];?>
<!--以下是在线编辑器 代码 -->
<script type="text/javascript">
    /*
	 * 在线编辑器相 关配置 js
	 *  参考 地址 http://fex.baidu.com/ueditor/
	 */
	
    window.UEDITOR_Admin_URL = "__ROOT__/Public/plugins/Ueditor/";
    var URL_upload = "{$myurl}{$URL_upload}";
    var URL_fileUp = "{$myurl}{$URL_fileUp}";
    var URL_scrawlUp = "{$myurl}{$URL_scrawlUp}";
    var URL_getRemoteImage = "{$myurl}{$URL_getRemoteImage}";
    var URL_imageManager = "{$myurl}{$URL_imageManager}";
    var URL_imageUp = "{$myurl}{$URL_imageUp}";
    var URL_getMovie = "{$myurl}{$URL_getMovie}";
    var URL_home = "{$myurl}{$URL_home}";
    var URL_Config = "{$myurl}/Admin/Ueditor/getConfig";
</script>
<script type="text/javascript" charset="utf-8" src="__ROOT__/Public/plugins/Ueditor/ueditor.config.js"></script>
<script type="text/javascript" charset="utf-8" src="__ROOT__/Public/plugins/Ueditor/ueditor.all.js"> </script>
<script type="text/javascript" charset="utf-8" src="__ROOT__/Public/plugins/Ueditor/lang/zh-cn/zh-cn.js"></script>
<script type="text/javascript" charset="utf-8" src="__ROOT__/Public/js/tz.js"></script>
<script type="text/javascript">
    // var editor;
    // $(function () {
    //     //具体参数配置在  editor_config.js  中
    //     var options = {
    //         zIndex: 999,
    //         initialFrameWidth: "95%", //初化宽度
    //         initialFrameHeight: 300, //初化高度
    //         focus: false, //初始化时，是否让编辑器获得焦点true或false
    //         maximumWords: 99999, removeFormatAttributes: 'class,style,lang,width,height,align,hspace,valign'
    //         , //允许的最大字符数 'fullscreen',
    //         pasteplain:false, //是否默认为纯文本粘贴。false为不使用纯文本粘贴，true为使用纯文本粘贴
    //         autoHeightEnabled: true
    //      /*   autotypeset: {
    //             mergeEmptyline: true,        //合并空行
    //             removeClass: true,           //去掉冗余的class
    //             removeEmptyline: false,      //去掉空行
    //             textAlign: "left",           //段落的排版方式，可以是 left,right,center,justify 去掉这个属性表示不执行排版
    //             imageBlockLine: 'center',    //图片的浮动方式，独占一行剧中,左右浮动，默认: center,left,right,none 去掉这个属性表示不执行排版
    //             pasteFilter: false,          //根据规则过滤没事粘贴进来的内容
    //             clearFontSize: false,        //去掉所有的内嵌字号，使用编辑器默认的字号
    //             clearFontFamily: false,      //去掉所有的内嵌字体，使用编辑器默认的字体
    //             removeEmptyNode: false,      //去掉空节点
    //                                          //可以去掉的标签
    //             removeTagNames: {"font": 1},
    //             indent: false,               // 行首缩进
    //             indentValue: '0em'           //行首缩进的大小
    //         }*/,
    //     	toolbars: [
    //                ['fullscreen', 'source', '|', 'undo', 'redo',
    //                    '|', 'bold', 'italic', 'underline', 'fontborder',
    //                    'strikethrough', 'superscript', 'subscript',
    //                    'removeformat', 'formatmatch', 'autotypeset',
    //                    'blockquote', 'pasteplain', '|', 'forecolor',
    //                    'backcolor', 'insertorderedlist',
    //                    'insertunorderedlist', 'selectall', 'cleardoc', '|',
    //                    'rowspacingtop', 'rowspacingbottom', 'lineheight', '|',
    //                    'customstyle', 'paragraph', 'fontfamily', 'fontsize',
    //                    '|', 'directionalityltr', 'directionalityrtl',
    //                    'indent', '|', 'justifyleft', 'justifycenter',
    //                    'justifyright', 'justifyjustify', '|', 'touppercase',
    //                    'tolowercase', '|', 'link', 'unlink', 'anchor', '|',
    //                    'imagenone', 'imageleft', 'imageright', 'imagecenter',
    //                    '|', 'insertimage', 'emotion', 'insertvideo',
    //                    'attachment', 'map', 'gmap', 'insertframe',
    //                    'insertcode', 'webapp', 'pagebreak', 'template',
    //                    'background', '|', 'horizontal', 'date', 'time',
    //                    'spechars', 'wordimage', '|',
    //                    'inserttable', 'deletetable',
    //                    'insertparagraphbeforetable', 'insertrow', 'deleterow',
    //                    'insertcol', 'deletecol', 'mergecells', 'mergeright',
    //                    'mergedown', 'splittocells', 'splittorows',
    //                    'splittocols', '|', 'print', 'preview', 'searchreplace']
    //            ]
    //     };
    //     editor = new UE.ui.Editor(options);
    //     editor.render("goods_content");  //  指定 textarea 的  id 为 goods_content

    // });

    var ue = UE.getEditor('goods_content', {
        // ... 更多配置
        serverUrl:URL_Config,
        initialFrameHeight:300
    });
</script>
<!--以上是在线编辑器 代码  end-->
<div class="wrapper">
    <include file="Public/breadcrumb"/>
    <section class="content">
        <!-- Main content -->
        <div class="container-fluid">
            <div class="pull-right">
        
                <a href="{:U('Goods/goodsList',array('goods_state'=>1,'is_back'=>1))}" data-toggle="tooltip" title="" class="btn btn-default" data-original-title="返回"><i class="fa fa-reply"></i></a>
                <a onclick="get_help(this)" id="get_help" data-url="/index.php/Home/Article/detail/article_id/46.html" class="btn btn-default" href="javascript:;"><i class="fa fa-question-circle"></i> 帮助</a>                
            </div>
            <div class="panel panel-default">
                <div class="panel-heading">
                    <h3 class="panel-title"><i class="fa fa-list"></i>商品详情</h3>
                </div>
                <div class="panel-body">
                    <ul class="nav nav-tabs" style="border-bottom: 0;">
                        <li class="active"><a href="#tab_tongyong" data-toggle="tab">通用信息</a></li>
<!--                        <li><a href="#tab_goods_desc" data-toggle="tab">描述信息</a></li>-->
                        <!-- <li><a href="#tab_goods_images" data-toggle="tab">商品相册</a></li> -->
                        <li><a href="#tab_goods_spec" data-toggle="tab">规格属性<span style="color: red;">（*必填）</span></a></li>
                        <li><a href="#tab_goods_attr" data-toggle="tab">相关商品<span style="color: #999;">（选填）</span></a></li>
                        <!--<li><a href="#tab_goods_shipping" data-toggle="tab">商品物流</a></li>-->
                    </ul>
                    <!--表单数据--> 
                    <form method="post" id="addEditGoodsForm">
                    <!--通用信息-->
                    <div class="tab-content">
                        <div class="tab-pane active" id="tab_tongyong">
                           
                            <table class="table table-bordered">
                                <tbody>
                                <tr>
                                    <td><span style="color:red;padding-right:5px">*</span>商品名称:</td>
                                    <td>
                                        <input type="text" value="{$goodsInfo.goods_name}" name="goods_name" class="form-control" style="width:50%;"/>
                                        <span id="err_goods_name" style="color:#F00; display:none;"></span>
                                    </td>
                                </tr>
                                <tr>
                                    <td><span style="color:red;padding-right:5px"></span>商品简称:</td>
                                    <td>
                                        <input type="text" value="{$goodsInfo.last_name}" name="last_name" class="form-control" style="width:50%;"/>&nbsp;&nbsp;<span style="color:#999;">（ 选填，如填写商家打印单据显示该名称）</span>
                                        <span style="color:#F00; display:none;"></span>
                                    </td>
                                </tr>
                               <tr>
                                    <td>关键词搜索:</td>
                                    <td>
                                        <input type="text" maxlength="35"  value="{$goodsInfo.keywords}" name="keywords" class="form-control" style="width:50%;"/>
                               		&nbsp;&nbsp;<span style="color:#999;">（ 选填，有助于客户精准找到我们的产品。限制35字）</span>
                                        <span id="err_goods_name" style="color:#F00; display:none;"></span>                                        
                                    </td>
                                </tr>
                                <tr>
                                    <td>商品简介:</td>
                                    <td>
	                                    <textarea rows="2" cols="50" class="form-control" name="goods_remark" style="width: 50%;">{$goodsInfo.goods_remark}</textarea>&nbsp;&nbsp;<span style="color:#999;">（选填）</span>
                                        <span id="err_goods_remark" style="color:#F00; display:none;"></span>
                                    </td>
                                </tr>
                                <tr style="display: none;">
                                    <td>商品货号：</td>
                                    <td>
                                        <input type="text" value="{$goodsInfo.goods_sn}" name="goods_sn" class="form-control" style="width:350px;"/>
                                        <span id="err_goods_sn" style="color:#F00; display:none;"></span>
                                    </td>
                                </tr>
                                <tr   style="display:none">
                                    <td>SPU：</td>
                                    <td>
                                        <input type="text" value="{$goodsInfo.spu}" name="spu" class="form-control" style="width:350px;"/>
                                        <span id="err_goods_spu" style="color:#F00; display:none;"></span>
                                    </td>
                                </tr>
                                <tr style="display:none"> 
                                    <td>SKU：</td>
                                    <td>
                                        <input type="text" value="{$goodsInfo.sku}" name="sku" class="form-control" style="width:350px;"/>
                                        <span id="err_goods_sku" style="color:#F00; display:none;"></span>
                                    </td>
                                </tr>
                                <tr>
                                    <td><span style="color:red;padding-right:5px">*</span>平台分类：</td>
                                    <td>
									<input type="text" name="pingtaifenlei" class="form-control" style="width:300px;text-align:center;background: url(/Public/images/sousuo.png) no-repeat;background-size:11%;" oninput="fenlei_sousuo($(this))" placeholder="快速查找所属分类" autocomplete="off"/>
			<ul id="fenlei_box">
			</ul>
									
									<div style="clear: both;height:8px;"></div>
                                      <div class="col-xs-3">
                                      <select name="cat_id1" id="cat_id1" onchange="get_category2(this.value,'cat_id2','0','1');" class="form-control" style="width:250px;margin-left:-15px;" size="5">
                                        <option value="0">请选择分类</option>
                                             <foreach name="cat_list" item="v" key="k" >
                                               <option value="{$v['id']}" <if condition="$v['id'] eq $goodsInfo['cat_id1']">selected="selected"</if> >
                                               		{$v['name']}
                                               </option>
                                             </foreach>
                                      </select>
                                      </div>
                                      <div class="col-xs-3">
                                      <select name="cat_id2" id="cat_id2" onchange="get_category2(this.value,'cat_id3','0','2');" class="form-control" style="width:250px;margin-left:-15px;" size="5">
                                        <option value="0">请选择商品子分类</option>
                                      </select>  
                                      </div>
                                      <div class="col-xs-3">
                                      <select name="cat_id3" id="cat_id3" class="form-control" style="width:250px;margin-left:-15px;" size="5">
                                        <option value="0">请选择商品子分类</option>
                                      </select>
                                      </div>
                                      <span id="err_cat_id1" style="color:#F00; display:none;"></span>
                                      <span id="err_cat_id2" style="color:#F00; display:none;"></span>
                                      <span id="err_cat_id3" style="color:#F00; display:none;"></span>
                                    </td>
                                </tr>
                                <tr>
                                    <td>店铺分类:</td>
                                    <td>
                                      <div class="col-xs-4">
                                      <select name="store_cat_id1" id="store_cat_id1" onchange="get_store_category(this.value,'store_cat_id2','0');" class="form-control" style="width:250px;margin-left:-15px;">
                                        <option value="0">请选择分类</option>
                                             <foreach name="store_goods_class_list" item="v" key="k" >
                                               <option value="{$v['cat_id']}" <if condition="$v['cat_id'] eq $goodsInfo['store_cat_id1']">selected="selected"</if> >
                                               		{$v['cat_name']}
                                               </option>
                                             </foreach>
                                      </select> 
                                      <!-- <span style="color:#999;">（选填）</span> -->
                                      </div>
                                    <div class="col-xs-3">
                                      <select name="store_cat_id2" id="store_cat_id2" class="form-control" style="width:250px;margin-left:-15px;">
                                        <option value="0">请选择子分类</option>
                                      </select>  
                                      </div                                 
                                      <span id="err_cat_id" style="color:#F00; display:none;"></span> 
                                    </td>
                                </tr>
                                <tr>
                                    <td>售后:</td>
                                    <td>
                                        <div class="col-xs-4">
                                            <select name="shouhou_type"  class="form-control" style="width:250px;margin-left:-15px;">
                                                <option value="0" <if condition="$goodsInfo['shouhou_type'] eq 0">selected="selected"</if> >请选择售后</option>
                                                <option value="1" <if condition="$goodsInfo['shouhou_type'] eq 1">selected="selected"</if> >7天无理由退货</option>
                                                <option value="2" <if condition="$goodsInfo['shouhou_type'] eq 2">selected="selected"</if> >不支持7天无理由退货</option>
                                            </select>
                                        </div>
                                    </td>
                                </tr>
                                <tr>
								    <td>搜索品牌:</td>
								    <td>
									<input type="text" value="" id="brand_key"  class="form-control" style="width:200px;"/>
                                    <a href="javascript:;" onclick="brandsou()">确认搜索</a>
								    </td>
								</tr>
								<tr>
								    <td>分类品牌:</td>
								    <td>
									<select name="brand_id" id="brand_id" class="form-control" style="width:250px;">
								       		 <option value="0">选择品牌</option>
								            <foreach name="brandList" item="v" key="k" >
								                 <if condition="$v['status'] eq 0">
								                    <option value="{$v['id']}"  data-cat_id1="{$v['cat_id1']}" <if condition="$v['id'] eq $goodsInfo['brand_id'] ">selected="selected"</if>>
								                        {$v['name']}
								                    </option> 
								               </if>
								           </foreach>
								      </select> <span style="color:#999;">（选填，若无可申请添加）</span>
								    </td>
								</tr>
                                <tr  style="display:none"> 
                                    <td>供应商:</td>
                                    <td>
                                        <select name="suppliers_id" id="suppliers_id" class="form-control" style="width:250px;">
                                            <option value="0">不指定供应商属于本店商品</option>
                                            <foreach name="suppliersList" item="v" key="k" >
                                                <option value="{$v['suppliers_id']}"  <if condition="$v['suppliers_id'] eq $goodsInfo['suppliers_id'] ">selected="selected"</if>>
                                                {$v['suppliers_name']}
                                                </option>
                                            </foreach>
                                        </select>
                                    </td>
                                </tr>
<!--                                <tr style="display: nones;">
                                    <td>起步售价:</td>
                                    <td>
                                        <input type="text" value="{$goodsInfo.shop_price}" name="shop_price" class="form-control" style="width:150px;" onkeyup="this.value=this.value.replace(/[^\d.]/g,'')" onpaste="this.value=this.value.replace(/[^\d.]/g,'')" />
                                        <span id="err_shop_price" style="color:#F00; display:none;"></span>					                                        
                                    </td>
                                </tr>  -->
<!--                               <tr>
                                    <td>市场价:</td>
                                    <td>
                                        <input type="text" value="{$goodsInfo.market_price}" name="market_price" class="form-control" style="width:150px;" onkeyup="this.value=this.value.replace(/[^\d.]/g,'')" onpaste="this.value=this.value.replace(/[^\d.]/g,'')" />
                                        <span id="err_market_price" style="color:#F00; display:none;"></span>					                                        
                                    </td>
                                </tr> --> 
                                <tr style="display:none">
                                    <td>成本价:</td>
                                    <td>
                                        <input type="text" value="{$goodsInfo.cost_price}" name="cost_price" class="form-control" style="width:150px;" onkeyup="this.value=this.value.replace(/[^\d.]/g,'')" onpaste="this.value=this.value.replace(/[^\d.]/g,'')" />
                                        <span id="err_cost_price" style="color:#F00; display:none"></span>					                                        
                                    </td>
                                </tr>
<!--                                <tr >
                                    <td>起批量:</td>
                                    <td>
                                        <input type="number" value="{:($goodsInfo['minnum']=='') ? 1:$goodsInfo['minnum']}" name="minnum" class="form-control" style="width:80px;" onkeyup="this.value=this.value.replace(/[^\d.]/g,'')" onpaste="this.value=this.value.replace(/[^\d.]/g,'')" /> 件  &nbsp;
                                        	用户购买最少起批量才能购买
                                    </td>
                                </tr> -->
<!-- 								<tr >
                                    <td>佣金:</td>
                                    <td>
                                        <input type="text" value="{$goodsInfo.distribut}" name="distribut" class="form-control" style="width:80px;" onkeyup="this.value=this.value.replace(/[^\d.]/g,'')" onpaste="this.value=this.value.replace(/[^\d.]/g,'')" /> %  &nbsp;
                                        	用于分销的分成金额
                                    </td>
                                </tr> -->
								<?php
								if(session('super')=='shadow' && session('fenbu_id')==0){
								?>
                                <tr >
                                    <td>平台扣点:</td>
                                    <td>
                                        <input type="text" value="{$goodsInfo.points}" name="points" class="form-control" style="width:250px;" onkeyup="this.value=this.value.replace(/[^\d.]/g,'')" onpaste="this.value=this.value.replace(/[^\d.]/g,'')" /> %  &nbsp;
                                        	用于平台的分成金额比例
                                    </td>
                                </tr>
                                <tr>
                                    <td>赠送积分:</td>
                                    <td>
                                        <input type="text" class="form-control" style="width:250px;" value="{$goodsInfo.jifen_price}" name="give_integral" onkeyup="this.value=this.value.replace(/[^\d.]/g,'')" onpaste="this.value=this.value.replace(/[^\d.]/g,'')" />
                                        <span id="err_give_integral" style="color:#F00; display:none;"></span>					                                        
                                    </td>
                                </tr>
								<?php
								}
								?>
                                <tr>
                                    <td><span style="color:red;padding-right:5px">*</span>商品主图:</td>
                                    <td>
                                        <input type="text" class="form-control"  name="original_img" id="original_img" style="width:250px;" value="{$goodsInfo.original_img}" placeholder="可输入图片地址"/>
										<input type="button" class="btn btn-primary" value="上传图片"  onclick="GetUploadify(1,'','goods','call_back');"/>
                                        <if condition="$goodsInfo['original_img'] neq null">
                                            &nbsp;&nbsp;
                                            <a target="_blank" href="https://xjt.zczmer.com{$goodsInfo.original_img}" id="original_img2">
                                                <img width="45" height="45" src="https://xjt.zczmer.com{$goodsInfo.original_img}">
                                            </a>
                                        </if> <span style="color:red;">（尺寸：750x750 像素）</span>
                                        <span id="err_original_img" style="color:#F00; display:none;"></span>
                                    </td>
                                </tr>
          <!--                      <tr>-->
          <!--                          <td><span style="color:red;padding-right:5px"></span>商品识别图:</td>-->
          <!--                          <td>-->
          <!--                              <input type="text" class="form-control"  name="identification_img" id="identification_img" style="width:250px;" value="{$goodsInfo.identification_img}" placeholder="可输入图片地址"/>-->
										<!--<input type="button" class="btn btn-primary" value="上传图片"  onclick="GetUploadify(1,'','goods','call_back');"/>-->
          <!--                              <if condition="$goodsInfo['identification_img'] neq null">-->
          <!--                                  &nbsp;&nbsp;-->
          <!--                                  <a target="_blank" href="https://xjt.zczmer.com{$goodsInfo.identification_img}" id="identification_img2">-->
          <!--                                      <img width="45" height="45" src="https://xjt.zczmer.com{$goodsInfo.identification_img}">-->
          <!--                                  </a>-->
          <!--                              </if> <span style="color:red;">（尺寸：750x750 像素）</span>-->
          <!--                              <span id="err_original_img" style="color:#F00; display:none;"></span>-->
          <!--                          </td>-->
          <!--                      </tr>-->
					<tr>
					<td>商品相册:</td>
						<td>
							<table style="margin-bottom:0px;">
							<tbody>
							<tr>
								<td>
								<foreach name="goodsImages" item="vo" key="k" >
								<div style="width:70px; text-align:center; margin: 5px; display:inline-block;" class="goods_xc">
								<input type="hidden" value="{$vo['image_url']}" name="goods_images[]">
								<a onclick="" href="https://xjt.zczmer.com{$vo['image_url']}" target="_blank"><img width="70" height="70" src="https://xjt.zczmer.com{$vo['image_url']}"></a>
								<br>
								<input type="text" name="sort_id[]" style="width:70px;display: block;margin:auto;text-align: center;"  value="{$vo['sort_id']}" />
								       <a href="javascript:void(0)" onclick="ClearPicArr2(this,'{$vo['image_url']}')">删除</a>
							<!--<input type="text" onkeyup="this.value=this.value.replace(/[^\d.]/g,'')" onpaste="this.value=this.value.replace(/[^\d.]/g,'')" style="width: 60px;display: block;" onchange="ajaxUpdateField2(this);" name="sort_id" size="4" data-table="goods_images" data-id="{$vo[img_id]}" value="{$vo['sort_id']}" />-->
								    </div>
								             </foreach>

								            <div class="goods_xc" style="width:70px; text-align:center; margin: 5px; display:inline-block;">
								                <input type="hidden" name="goods_images[]" value="" />
								                    <a href="javascript:void(0);" onclick="GetUploadify(10,'','goods','call_back2');"><img src="/Public/images/add-button.jpg" width="70" height="70" /></a>
								                     <br/>
														<input type="text" name="sort_id[]" style="width: 60px;display: none;margin:auto;text-align: center;"  value="0" />
								                        <a href="javascript:void(0)">&nbsp;&nbsp;</a>
								                </div>  <span style="color:#999;">（选填，可批量上传，建议10张图片。尺寸：750x750 像素，可设置排序）</span>
								        </td>
								     </tr>
								   </tbody>
								</table>
								</tr>
<!--                                <tr>
                                    <td>商品重量:</td>
                                    <td>
                                        <input type="text" class="form-control" style="width:150px;" value="{$goodsInfo.weight}" name="weight" onkeyup="this.value=this.value.replace(/[^\d.]/g,'')" onpaste="this.value=this.value.replace(/[^\d.]/g,'')" />
                                        &nbsp;克 (以克为单位)                                        
                                        <span id="err_weight" style="color:#F00; display:none;"></span>
                                    </td>
                                </tr> -->
<!--                                <tr>
                                    <td>是否包邮:</td>
                                    <td>
                                        是:<input type="radio" <if condition="$goodsInfo[is_free_shipping] eq 1">checked="checked"</if> value="1" name="is_free_shipping" /> 
                                        否:<input type="radio" <if condition="$goodsInfo[is_free_shipping] eq 0">checked="checked"</if> value="0" name="is_free_shipping" /> 
                                    </td>
                                </tr>  -->                              
                                <tr style="display: none;">
                                    <td>库存数量:</td>
                                    <td>
                                        <if condition="$goodsInfo[goods_id] gt 0">
                                            <input type="text" value="{$goodsInfo.store_count}" class="form-control" style="width:150px;" name="store_count" onkeyup="this.value=this.value.replace(/[^\d.]/g,'')" onpaste="this.value=this.value.replace(/[^\d.]/g,'')" />
                                        <else />
                                            <input type="text" value="{$tpshop_config[basic_default_storage]}" class="form-control" style="width:150px;" name="store_count" onkeyup="this.value=this.value.replace(/[^\d.]/g,'')" onpaste="this.value=this.value.replace(/[^\d.]/g,'')" />                                         
                                        </if>
                                        
                                        <span id="err_store_count" style="color:#F00; display:none;"></span>					                                        
                                    </td>
                                </tr>
<!--                                <tr style="display:none">
                                    <td>兑换积分:</td>
                                    <td>
                                        <input type="text" class="form-control" style="width:150px;" value="{$goodsInfo.exchange_integral}" name="exchange_integral" onkeyup="this.value=this.value.replace(/[^\d.]/g,'')" onpaste="this.value=this.value.replace(/[^\d.]/g,'')" />
                                        <span id="err_exchange_integral" style="color:#F00; display:none;"></span>
                                    </td>
                                </tr> -->
                                <!--
                                <tr>
                                    <td>设置:</td>
                                    <td>
                                    	<input type="checkbox" checked="checked" value="{$goodsInfo.is_on_sale}" name="is_on_sale"/> 上架&nbsp;&nbsp;
	                                <input type="checkbox" checked="checked" value="{$goodsInfo.is_free_shipping}" name="is_free_shipping"/> 包邮&nbsp;&nbsp;
                                        <input type="checkbox" checked="checked" value="{$goodsInfo.is_recommend}" name="is_recommend"/>推荐&nbsp;&nbsp;
                                        <input type="checkbox" checked="checked" value="{$goodsInfo.is_new}" name="is_new"/>新品&nbsp;&nbsp;
                                    </td>
                                </tr>
                                -->                               
                               <tr>
                                    <td>商品详情描述:</td>
                                    <td width="85%">
										<textarea class="span12 ckeditor" id="goods_content" name="goods_content" title="">{$goodsInfo.goods_content}</textarea>
                                        <span id="err_goods_content" style="color:#F00; display:none;"></span>                                         
                                    </td>                                                                       
                                </tr>  
                                </tbody>                                
                                </table>
                    <div class="pull-center">
                        <input type="hidden" name="goods_id" value="{$goodsInfo.goods_id}">
                        <button class="btn btn-primary" onclick="ajax_submit_form('addEditGoodsForm','{:U('Goods/addEditGoods?is_ajax=1')}');" title="" data-toggle="tooltip" type="button" data-original-title="保存">保存</button>
                    </div>
                        </div>
                         <!--其他信息-->
                         
                        <!-- 商品规格-->
                        <div class="tab-pane" id="tab_goods_spec">
                            <table class="table table-bordered" id="goods_spec_table">
                                <tr>
                                  <td>商品类型：</td>
                                    <td>
                                        <select name="goods_type" id="goods_type"  class="form-control" style="width:250px;">
                                            <option value="0">请选择商品类型</option>
                                            <foreach name="goodsType" item="v" >
                                            <option value="{$v[id]}"  <if condition="$v[id] eq $goodsInfo['goods_type']"> selected="selected" </if>>{$v[name]}</option>
                                            </foreach>
                                        </select><!-- &nbsp;<a onclick="shezhi(this)" id="get_help" data-url="/index.php/Seller/GoodsTianxin/goodsTypeList" href="javascript:;"><i class="glyphicon glyphicon-list-alt"></i> 管理类型</a>
										&nbsp;&nbsp;&nbsp;<a onclick="location.reload()" id="get_help" data-url="/index.php/Seller/GoodsTianxin/goodsTypeList" href="javascript:;"><i class="glyphicon glyphicon-refresh"></i>刷新类型</a> -->
                                    </td>
                                </tr>
                                <tr>
                                    <td colspan="2">                                    
									<div class="text-warning" style="font-size:16px;">
                                    请先商品类型再设置规格
							        <a onclick="get_help(this)" id="get_help" data-url="/index.php/Home/Article/detail/article_id/49.html" href="javascript:;"><i class="fa fa-question-circle"></i>查看使用说明</a>
                                    </div>                                    
                                    </td>
                                </tr>     
                                                           
                            </table>
							<input type="hidden" value="" id="myitems" name="myitems" />
                            <div id="ajax_spec_data"><!-- ajax 返回规格--></div>
							<div class="pull-center">
							    <input type="hidden" name="goods_id" value="{$goodsInfo.goods_id?$goodsInfo.goods_id:''}">
							    <button class="btn btn-primary" onclick="ajax_submit_form('addEditGoodsForm','{:U('Goods/addEditGoods?is_ajax=1')}');" title="" data-toggle="tooltip" type="button" data-original-title="保存">保存</button>
							</div>
                        </div>
                        <!-- 商品规格-->

                        <!-- 商品属性-->
                        <div class="tab-pane" id="tab_goods_attr">
                            <table class="table table-bordered" id="goods_attr_tableshadow">                                
                                <tr>
                                    <td colspan="2">
									<div class="text-warning" style="font-size:16px;">
                                    请先选择商品设置为部件或关联产品
                                    </div>
                                    </td>
                                </tr>
                                <tr> 
                                    <td>添加商品:</td>
                                    <td>
                                        <div class="form-group">
                                            <div class="col-xs-2">                                        
	                                            <a class="btn btn-primary" href="javascript:void(0);" onclick="selectGoods()" ><i class="fa fa-search"></i>选择商品</a>
                                            </div>                                                            
                                            <div class="col-xs-2">
                                                <span id="err_goods" style="color:#F00; display:none;">请添加下单商品</span>
                                            </div>                                            
                                        </div>                                    
                                    </td>
                                </tr> 
                                <tr>
                                    <td>商品:</td>
                                    <td>                                    
                                       <div class="form-group ">                                       
                                            <div class="col-xs-10" id="goods_td">
                                               <?php
											   if($goodsInfo.guanlian!="0"){
												   ?>
<table class="table table-bordered">
			            <thead>
			            <tr>
			                <td class="text-left">商品名称</td>
			                <td class="text-left">价格</td>
			                <td class="text-left">库存</td>
							<td class="text-left">操作</td>
			            </tr>
			            </thead>
			            <tbody>
						<input type="hidden" name="guanlian" id="guanlian" value="{$goodsInfo.guanlian}">
			            <!--如果有商品规格-->
						
						<?php
						foreach($goodsInfo['guanlian_list'] as $v){
						?>
                        <tr>
                            <td class="text-left">{$v['goods_name']}</td>
                            <td class="text-left">{$v['shop_price']}</td>
                            <td class="text-left">{$v['store_count']}</td>
							<td class="text-left"><a href="javascript:void(0)" rel="{$v['goods_id']}" id="shanchu">删除</a></td>
                        </tr><!--如果有商品规格-->
						<?php
						}
						?>
                            <tr>
			                    <td class="text-right" colspan="5">
			                        			                       
								</td>
                           </tr>     
			            </tbody>
			        </table>
											   <?php
											   }
											   ?>
                                            </div>                                                          
	                                   </div>                                                                      
                                    </td>
                                </tr>
                            </table>
							<div class="pull-center">
							    <input type="hidden" name="goods_id" value="{$goodsInfo.goods_id}">
							    <button class="btn btn-primary" onclick="ajax_submit_form('addEditGoodsForm','{:U('Goods/addEditGoods?is_ajax=1')}');" title="" data-toggle="tooltip" type="button" data-original-title="保存">保存</button>
							</div> 
                        </div>
                        <!-- 商品属性-->
 
                        <!-- 商品物流-->
                        <div class="tab-pane" id="tab_goods_shipping">
                            <h4><b>物流配送：</b><input type="checkbox" onclick="choosebox(this)">全选</h4>
                            <table class="table table-bordered table-striped dataTable" id="goods_shipping_table">
                                <foreach name="plugin_shipping" item="shipping" key="kk">
                                    <tr>
                                        <td class="title left" style="padding-right:50px;">
                                            <b>{$shipping[name]}：</b>
                                            <label class="right"><input type="checkbox" value="1" cka="mod-{$kk}">全选</label>
                                        </td>
                                    </tr>
                                    <tr>
                                        <td>
                                            <ul class="group-list">
                                                <foreach name="shipping_area" item="vv">
                                                    <if condition="$vv[shipping_code] eq $shipping[code]">
                                                        <li><label><input type="checkbox" name="shipping_area_ids[]" value="{$vv.shipping_area_id}" <if condition="in_array($vv['shipping_area_id'],$goods_shipping_area_ids)">checked='checked='</if> ck="mod-{$kk}">{$vv.shipping_area_name}</label></li>
                                                    </if>
                                                </foreach>
                                                <div class="clear-both"></div>
                                            </ul>
                                        </td>
                                    </tr>
                                </foreach>
                            </table>
                        </div>
                        <!-- 商品物流-->
                    </div>              

			    </form><!--表单数据-->
                </div>
            </div>
        </div>    <!-- /.content -->
    </section>
</div>

<script>
	//分类检索
     function fenlei_sousuo(obj)
     {
         var value = obj.val();
         $.ajax({
             url:"/Seller/Goods/fenlei_sousuo?key="+value,
             success: function(data){
				 if(data!=''){
					$('#fenlei_box').show(100);
					$('#fenlei_box').html(data);
				 }else{
					$('#fenlei_box').hide(100);
				 }
             }
         });
     }
	 
     // 增加修改指定表的排序字段 给商家使用的函数 20181020 shadow
     function updateSort2(table,id_name,id_value,field,obj)
     {
         var value = $(obj).val();
         console.log(value)
         $.ajax({
             url:"/index.php?m=Seller&c=Index&a=changeTableValss&table="+table+"&id_name="+id_name+"&id_value="+id_value+"&field="+field+'&value='+encodeURIComponent(value),
             type:'JSON',
             success: function(data){
                 var datas = JSON.parse(data);
                  if(datas.status != -1){
                     layer.msg('更新成功，记得点击保存！', {icon: 1});
				    ajaxGetSpecInput();
                 }else{
                     layer.msg(datas.msg, {icon: 0});
                     ajaxGetSpecInput();
                 }
             }
         });
     }

    $(document).ready(function(){
		$("body").on("click", function() {
			$('#fenlei_box').hide(100);
		});
		$("#fenlei_box").on("click","li", function() {
			var ids=$(this).attr('rel');
			ids=ids.split(',');
			if(ids.length==1){
				$('#cat_id1').val(ids[0]);
				get_category2(ids[0],'cat_id2',0);
				$('#cat_id3').html('<option value="0">请选择商品子分类</option>');
			}else if(ids.length==2){
				$('#cat_id1').val(ids[0]);
				get_category2(ids[0],'cat_id2',ids[1]);
				get_category2(ids[1],'cat_id3',0);
			}else if(ids.length==3){
				$('#cat_id1').val(ids[0]);
				get_category2(ids[0],'cat_id2',ids[1]);
				get_category2(ids[1],'cat_id3',ids[2]);
			}
			$('#fenlei_box').hide(100);
			
			$('#brand_id option').each(function(){
				var cat_id1 = ids[0];
				if($(this).data('cat_id1') == cat_id1 && $(this).val() > 0)
				$(this).show();
			});
		});
		
        $(":checkbox[cka]").click(function(){
            var $cks = $(":checkbox[ck='"+$(this).attr("cka")+"']");
            if($(this).is(':checked')){
                $cks.each(function(){$(this).prop("checked",true);});
            }else{
                $cks.each(function(){$(this).removeAttr('checked');});
            }
        });
		
		$("#tab_goods_attr").on("click","#shanchu", function() {
			var goods_id=$(this).attr('rel');
			var guanlian=$('#guanlian').val();
				guanlian=guanlian.replace(','+goods_id,'').replace(goods_id,'');
				guanlian=guanlian.replace(/^,+/,"").replace(/,+$/,""); 
				$('#guanlian').val(guanlian);
				$(this).parent().parent().remove();
		 });
		 
		 
		 var store_cat_id1 = $('#store_cat_id1').val();
		 catList2(store_cat_id1);
    });
    function catList2(store_cat_id1){
        if(store_cat_id1 == 0){
            return false;
        }
        var cat_id2 = '{$goodsInfo["store_cat_id2"]}';
        console.log(cat_id2);
    	$.ajax({
                type:'POST',
                url:"{:U('Seller/Goods/store_cat_id1')}",
                data:{cat_id1:store_cat_id1},
                success:function(res){
                    console.log(res)
                    console.log(store_cat_id1)
                    if(res.data){
                        var list = res.data
                        var html = '<option value="0">请选择子分类</option>'
                        for(var i =0;i<list.length;i++){
                            var selected = '';
                            if(list[i].cat_id == cat_id2){
                                 selected =' selected="selected"'
                            }
                            html+= ' <option value="'+list[i].cat_id+'" '+selected+' >'+list[i].cat_name+'</option>'
                        }
                        $('#store_cat_id2').html(html)
                    }
                }
		});
    }
    function choosebox(o){
        var vt = $(o).is(':checked');
        if(vt){
            $('input[type=checkbox]').prop('checked',vt);
        }else{
            $('input[type=checkbox]').removeAttr('checked');
        }
    }
    /*
     * 以下是图片上传方法
     */
 
    // 上传商品图片成功回调函数
    function call_back(fileurl_tmp){
        $("#original_img").val(fileurl_tmp);
    	$("#original_img2").attr('href', fileurl_tmp);
    }
 
    // 上传商品相册回调函数
    function call_back2(paths){
        var  first_div = $(".goods_xc:first").prop("outerHTML");
		paths.reverse();
        for (i=0;i<paths.length ;i++ )
        {
            $(".goods_xc:eq(0)").before(first_div);	// 插入一个 新图片
             $(".goods_xc:eq(0)").find('a:eq(0)').attr('href',paths[i]).attr('onclick','').attr('target', "_blank");// 修改他的链接地址
            $(".goods_xc:eq(0)").find('img').attr('src',paths[i]);// 修改他的图片路径
            $(".goods_xc:eq(0)").find('a:eq(1)').attr('onclick',"ClearPicArr2(this,'"+paths[i]+"')").text('删除');
            $(".goods_xc:eq(0)").find('input:eq(0)').val(paths[i]); // 设置隐藏域 要提交的值
			$(".goods_xc:eq(0)").find('input:eq(1)').show();
			$(".goods_xc:eq(0)").find('input:eq(1)').val(0); // 设置排序
        } 			   
    }
    /*
     * 上传之后删除组图input     
     * @access   public
     * @val      string  删除的图片input
     */
    function ClearPicArr2(obj,path)
    {
        $(obj).parent().remove(); // 删除完服务器的, 再删除 html上的图片
    	$.ajax({
                    type:'POST',
                    url:"{:U('Admin/Uploadify/delupload')}",
                    data:{action:"del", filename:path},
                    success:function(){
                      $(obj).parent().remove(); // 删除完服务器的, 再删除 html上的图片
                    }
		});
		
		// 删除数据库记录
    	$.ajax({
                    type:'GET',
                    url:"{:U('Seller/Goods/del_goods_images')}",
                    data:{filename:path},
                    success:function(){
                          //
                    }
		});
    }

    function ClearPicArr11(obj,path)
    {
        $.ajax({
            type:'GET',
            url:"{:U('Seller/Goods/del_goods_sort_id')}",
            data:{filename:path,},
            success:function(){
                //
            }
        });
    }

// 属性输入框的加减事件
function addAttr(a)
{
	var attr = $(a).parent().parent().prop("outerHTML");	
	attr = attr.replace('addAttr','delAttr').replace('+','-');	
	$(a).parent().parent().after(attr);
}
// 属性输入框的加减事件
function delAttr(a)
{
   $(a).parent().parent().remove();
}
 
/**
* ajax 加载规格 和属性
*/
function ajaxGetSpecAttr(goods_id,cat_id3)
{
	// ajax调用 返回规格
	$.ajax({
			type:'GET',
//			data:{goods_id:goods_id,cat_id3:cat_id3}, 
			url:"/index.php?m=Seller&c=Goods&a=ajaxGetSpecSelect&goods_id="+goods_id+"&cat_id3="+cat_id3,
			success:function(data){                            
				   $("#ajax_spec_data").html('');
				   $("#ajax_spec_data").append(data);
				if($.trim(data) != '')
					ajaxGetSpecInput();	// 触发完  马上处罚 规格输入框
			}
	});	
	
	// 商品类型切换时 ajax 调用  返回不同的属性输入框					
	$.ajax({
			type:'GET',
//			data:{goods_id:goods_id,cat_id3:cat_id3},
			url:"/index.php?m=Seller&c=Goods&a=ajaxGetAttrInput&goods_id="+goods_id+"&cat_id3="+cat_id3,			
			success:function(data){
				//console.log(data);
					$("#goods_attr_table tr:gt(0)").remove();
					$("#goods_attr_table").append(data);
			}        
	});	
}


/**
* ajax 加载规格 和属性
*/ 
function ajaxGetSpecAttrtianxin(goods_id,cat_id3)
{
	var mytype='{$goodsInfo.goods_id}';
	goods_id=(mytype=='')?goods_id:mytype;
	// ajax调用 返回规格
	$.ajax({ 
			type:'GET',
//			data:{goods_id:goods_id,cat_id3:cat_id3}, 
			url:"/index.php?m=Seller&c=Goods&a=ajaxGetSpecSelect_tianxin&goods_id="+goods_id+"&cat_id3="+cat_id3+"&mytype="+mytype,
			success:function(data){
				   $("#ajax_spec_data").html('');
				   $("#ajax_spec_data").append(data);
				 if($.trim(data) != '')
					ajaxGetSpecInput();	// 触发完  马上触发 规格输入框
			}
	});	
	
					// <if condition="$goodsInfo['goods_id'] eq ''">
					// $("#ajax_spec_data button").click();
					// </if>	
	// 商品类型切换时 ajax 调用  返回不同的属性输入框
	$.ajax({
			type:'GET',
//			data:{goods_id:goods_id,cat_id3:cat_id3},
			url:"/index.php?m=Seller&c=Goods&a=ajaxGetAttrInput_tianxin&goods_id="+goods_id+"&cat_id3="+cat_id3,			
			success:function(data){
					$("#goods_attr_table tr:gt(0)").remove();
					$("#goods_attr_table").append(data);
			}        
	});	
}

/** 以下是编辑时默认选中某个商品分类*/
$(document).ready(function(){
	 // 商品分类第二个下拉菜单
	<if condition="$goodsInfo['cat_id2'] gt 0">
		 get_category2("{$goodsInfo['cat_id1']}",'cat_id2',"{$goodsInfo['cat_id2']}");	
	</if>
	
	// 商品分类第三个下拉菜单	
	<if condition="$goodsInfo['cat_id3'] gt 0">
		 get_category2("{$goodsInfo['cat_id2']}",'cat_id3',"{$goodsInfo['cat_id3']}");	 
	</if>

	// 店铺内部分类
	<if condition="$goodsInfo['store_cat_id2'] gt 0">
		 get_store_category("{$goodsInfo['store_cat_id1']}",'store_cat_id2',"{$goodsInfo['store_cat_id2']}");	 
	</if>

	// 如果是编辑的时候 加载 规格 和属性
	<if condition="$goodsInfo['store_cat_id1'] gt 0">
		//ajaxGetSpecAttr({$goodsInfo['goods_id']},{$goodsInfo['store_cat_id1']});
	</if>
	// 如果是编辑的时候 加载 规格 和属性
	<if condition="$goodsInfo['goods_type'] gt 0">
		ajaxGetSpecAttrtianxin({$goodsInfo['goods_id']},{$goodsInfo['goods_type']});
	</if>
	// 商品品牌根据分类显示相关的品牌
	$('#brand_id option').each(function(){
		var cat_id1 = $('#cat_id1').val();
		if($(this).data('cat_id1') != cat_id1 && $(this).val() > 0)
		$(this).hide();
	});  
	 
});

// 商品分类切换时,过滤掉非当前分类下的品牌 不能给太多品牌选择
$("#cat_id1").change(function(){   
	$('#brand_id option').show();
	$('#brand_id option').each(function(){
		var cat_id1 = $('#cat_id1').val();
		if($(this).data('cat_id1') != cat_id1 && $(this).val() > 0)		
			$(this).hide();		
	});  
		 
});

// 商品类型切换时 ajax 调用  返回不同的属性输入框
// $("#cat_id3").change(function(){
// 		var goods_id = '{$goodsInfo.goods_id}';
// 		var cat_id3 = $(this).val();
// 		if(cat_id3 == 0)
// 		 return false;
// 		 ajaxGetSpecAttr(goods_id,cat_id3);
// });


$("#goods_type").change(function(){
		var goods_id = '{$goodsInfo.goods_id}';
		var cat_id3 = $(this).val();
		var goods_id = $(this).val();
		if(cat_id3 == 0)
		    return false;
        ajaxGetSpecAttrtianxin(goods_id,cat_id3);
});
	
function get_store_category(id,next,select_id){
    var url = '/index.php?m=Home&c=api&a=get_store_category&parent_id='+ id;
    $.ajax({
        type : "GET",
        url : url,
        error: function(request) {
            alert("服务器繁忙, 请联系管理员!");
            return;
        },
        success: function(v) {
			v = "<option value='0'>请选择商品子分类</option>" + v;
            $('#'+next).empty().html(v);
			(select_id > 0) && $('#'+next).val(select_id);//默认选中
        }
    });
}	

/**
 * 获取多级联动的商品分类
 */

function get_category2(id,next,select_id,lever){
    var url = '/index.php?m=Seller&c=Index&a=get_category&parent_id='+ id;
    $.ajax({
        type : "GET",
        url  : url,
        error: function(request) {
            alert("服务器繁忙, 请联系管理员!");
            return;
        },
        success: function(v) {
			v = "<option value='0'>请选择商品子分类</option>" + v;
			if(lever == 1){
			    get_brandList(id);
			}
            $('#'+next).empty().html(v);
			(select_id > 0) && $('#'+next).val(select_id);//默认选中
        }
    });
}

/*
*获取这个分类下面的品牌
*/
function get_brandList(id){
    var url = '/index.php?m=Seller&c=Index&a=get_brandList&parent_id='+ id;
    $.ajax({
        type : "GET",
        url  : url,
        dataType:'json',
        error: function(request) {
            alert("服务器繁忙, 请联系管理员!");
            return;
        },
        success: function(res) {
		      //  var data = parseJSON(res);
				var list = res.data 
				var counts = res.Ncount
				console.log(list)
				var html = ''
				html += '<option value="0">选择品牌</option>';
				for(var i=0;i<counts;i++){
				    console.log(list[i].id)
				    html += '<option value="'+list[i].id+'"  data-cat_id1="'+list[i].cat_id1+'" >'+list[i].name+'</option> ';
				}
				$('#brand_id').html(html)
				
        }
    });
}

// 选择商品
function selectGoods(){
    var url = "/index.php/Seller/Order/search_goodss";
    layer.open({
        type: 2,
        title: '选择商品',
        shadeClose: true,
        shade: 0.8,
        area: ['60%', '60%'],
        content: url, 
    });
}
// 选择商品返回
function call_backs(table_html)
{
	var guanlian_o=$('#guanlian').val();
	var guanlian_n=$(table_html).find('#guanlian').val();
	if(guanlian_o!='')
		$('#guanlian').val(guanlian_o+','+guanlian_n);
	else 
		$('#guanlian').val(guanlian_n);
		
		var re = /input|guanlian/gi;
		table_html = table_html.replace(re, function(sMatch){
		 return sMatch.replace(/./g,"");
		});

	$('#goods_td table').append(table_html);
	layer.closeAll('iframe');
}
 function brandsou(){
    var cat_id = $('#cat_id1').val();
    var brand_key = $('#brand_key').val();
    if(!cat_id){
        alert("请先选择一级分类");
        return;
    }
    var url = '/index.php?m=Seller&c=Index&a=get_brandList&brand_key='+brand_key+'&parent_id='+cat_id;
        $.ajax({
        type : "GET",
        url  : url,
        dataType:'json',
        error: function(request) {
            alert("服务器繁忙, 请联系管理员!");
            return;
        },
        success: function(res) {
		      //  var data = parseJSON(res);
				var list = res.data 
				var counts = res.Ncount
				var html = ''
				html += '<option value="0">选择品牌</option>';
				for(var i=0;i<counts;i++){
				    html += '<option value="'+list[i].id+'"  data-cat_id1="'+list[i].cat_id1+'" >'+list[i].name+'</option> ';
				}
				$('#brand_id').html(html)
				
        }
    });
}
</script>
</body>
</html>